﻿package nl.sanity.puremvc.model 
{
	import org.puremvc.as3.interfaces.IProxy;
    import org.puremvc.as3.patterns.proxy.Proxy;
	import org.puremvc.as3.utilities.startupmanager.model.StartupResourceProxy;
	
	import nl.sanity.debug.LogConsole;

	/**
	 * EntityProxy
	 * Base class for startup resource proxies, such as the StyleSheetProxy and the DataProxy.
	 * 
	 * @langversion ActionScript 3
	 *
	 * @author A. Gosman
	 * @since  28/03/2009
	 */
    public class EntityProxy extends Proxy implements IProxy
    {
		protected var _url				: String;
		
		// --- CONSTRUCTOR ----------------------------------------

		public function EntityProxy ( name:String, url:String = null )
        {
            super ( name );
			
			_url = url;
        }
		
		// --- PROTECTED FUNCTIONS ----------------------------------------

		protected function sendLoadedNotification( notificationName:String, notificationBody:String, srName:String ):void
		{
			var srProxy:StartupResourceProxy = facade.retrieveProxy( srName ) as StartupResourceProxy;
			
			LogConsole.info ( "EntityProxy.sendLoadedNotification: " + notificationName + " srName: " + srName + " resourceProxy: " + srProxy );
			
			if ( !srProxy.isTimedOut() )
			{
				sendNotification( notificationName, notificationBody );
			}
		}
	}
}